/**
 * 1.动态列数据
 * 2.被勾选的动态列数据
 * 3.table的列数据
 */
import DynamicData from './DynamicData'
import { ref, watch } from 'vue'
import { watchSwitchLang } from '@/utils/i18n'
// 暴露出的动态列数据

export const dynamicData = ref(DynamicData())

export const selectDynamicLabel = ref([])
watchSwitchLang(() => {
  dynamicData.value = DynamicData()
  initSelectDynamicLabel()
})
const initSelectDynamicLabel = () => {
  selectDynamicLabel.value = dynamicData.value.map((item) => item.label)
}
initSelectDynamicLabel()

export const tableColumns = ref([])
watch(
  selectDynamicLabel,
  (val) => {
    tableColumns.value = []
    const selectData = dynamicData.value.filter((item) => {
      return val.includes(item.label)
    })
    tableColumns.value.push(...selectData)
  },
  {
    immediate: true
  }
)
